Skip to content

fix(core): 删除无调用方的代码并修正仍按双客户端描述的注释和文档 - #258

Merged
xiaoyumuxi merged 1 commit into
mainfrom
refactor/structure-cleanup
Dec 3, 2026
Merged

xiaoyumuxi merged 1 commit into
mainfrom
refactor/structure-cleanup

Conversation

@xiaoyumuxi

Copy link
Copy Markdown
Contributor

关联 Issue

1lck/Lithe-IDEA#2651 登记的是删除旧客户端之后 Core 里需要单独设计才能处理的部分(桌面端不再调用的命令的去留、仅测试使用的生产接口、契约文档按单客户端重写)。本 PR 只做同一次扫描里可以直接处理、不改变行为的部分,不关闭它。桌面端一侧的对应清理在 1lck/Lithe-IDEA#2652。

背景

删除 Swift、Tauri 两个旧客户端之后,Core 里留下两类东西:没有任何调用方的公开常量和函数;注释和文档里仍按“macOS SwiftUI + Windows Tauri 两个宿主”描述的说法。现在只有一个 Go 桌面端通过 cgo 链接 Core,这些说法会让读代码的人去找不存在的调用方。

共 38 个文件,+45 / −175。没有行为变化,没有协议、契约或能力版本变化。

改动

1. 删除没有调用方的代码

每一项都在 Core 仓库和桌面端仓库(1lck/Lithe-IDEA 的 desktop/)里搜索过,确认没有调用方,包括测试和按字符串分发的调用。

位置 删除的内容
rust/crates/agent-runtime/src/lib.rs 四张命令名单常量 AGENT_COMMANDS、AGENT_SESSION_COMMANDS、AGENT_LIBRARY_COMMANDS、AGENT_PROVIDER_COMMANDS。命令分发不读这些名单,删掉不影响任何命令
rust/crates/core/src/lib.rs start_lsp_owned
rust/crates/lsp-engine/src/lib.rs 自由函数 start_server_owned
rust/crates/core-rules/src/visibility.rs is_hidden_directory_name
rust/crates/diagnostics/src/channel.rs 常量 CHANNEL_ROOTS
rust/crates/diagnostics/src/logging.rs 常量 DIAGNOSTIC_DURATION_MS
rust/crates/plugin-marketplace/src/lib.rs 常量 KNOWN_PLATFORMS
rust/crates/remote/src/failure_log.rs 常量 LIFECYCLE_EVENTS
rust/crates/workspace/src/test_support.rs devcontainer_up_with

2. 去掉两个未使用的依赖

  • rust/crates/agent-runtime/Cargo.toml:lithe-plugin-model
  • rust/crates/core/Cargo.toml:lithe-plugin-ui

rust/Cargo.lock 随之少两行,没有版本变化。

3. 注释里按双客户端描述的说法

只改注释和测试里的注释,不改代码。“both hosts / two hosts / both products / either platform”改为“every host / a host”;“so the Windows frontend can run it synchronously”这类已不成立的理由删除;NSTextView、“JavaScript string indices”这类指向旧客户端实现的说法改为与宿主无关的描述。涉及的文件:

build/src/test_outcome.rs、build/src/test_outcome_merge.rs、core-rules/src/editor/workbench_state.rs、core/src/protocol/command.rs、core/src/tests/declarative_plugins.rs、debug/src/variable_paging.rs、diagnostics/src/logging.rs、diff/src/tests.rs、editor/src/line_edit.rs、git-host/src/lib.rs、git/src/branch_names.rs、git/src/graph.rs、git/src/lib.rs、network/src/lib.rs、plugin-manifest/src/lib.rs、plugin-manifest/src/views.rs、plugin-model/src/lib.rs、plugin-model/src/settings.rs、process/src/inventory.rs、process/src/lifecycle.rs、project/src/encoding.rs、request-context/src/events.rs、vcs/src/model.rs(都在 rust/crates/ 下)。

4. 文档

  • rust/contracts/rust-core-api.md:开头从“macOS SwiftUI 和 Windows React/Tauri 共用,macOS 走 C ABI、Tauri 直接链接 crate”改为“Go 桌面端通过 cgo 链接 staticlib 并调用 C ABI”;C ABI 清单补上头文件里已有、文档漏掉的 lithe_core_is_plain_text 和 lithe_core_execute_document_json;删掉已不存在的 macos/Sources/LitheRustCore/ 桥接说明,保留对 rust/crates/core/include/lithe_core.h 的指向。
  • README.md(中英两处):官方 SDK 列表从 sdk/{node,java,rust} 改为实际的 sdk/{rust,go,node,java}。
  • rust/logging/README.md:“Sparkle differential-update baselines”改为“Viva incremental-patch baselines”。
  • shared/plugins/contract/v1/README.md:“one Monaco undo step”改为“one editor undo step”。只改措辞,没有改任何方法、参数、返回值或行为,所以没有在插件协议更新记录里加条目。

不在本 PR 范围内

验证

在 macOS arm64 上,基于变基到 main(5dfe7970,含 #257)之后的提交运行:

命令 结果
cargo fmt --check 通过
cargo clippy --locked --workspace --all-targets --all-features -- -D warnings 通过
cargo clippy --locked --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings 通过
cargo test --locked --workspace --all-features --no-fail-fast 139 个测试程序通过;lithe-core 的 plugin_sdk_build(2 个测试)失败,见下
node scripts/logging/generate-log-events.mjs --check 通过
node scripts/rust-core/verify-platform-tests.mjs 通过
scripts/rust-core/verify-rust-core-comments.sh 通过
node shared/plugins/scripts/verify-docs.mjs 通过

没有通过或没有运行的检查:

  • plugin_sdk_build 的两个测试(node_sdk_serves_native_build_test_and_run_workflows、java_sdk_serves_native_build_test_and_run_workflows)在直接运行 cargo test --workspace 时失败:它们需要 shared/plugins/scripts/sdk-e2e.mjs 准备的环境变量。在没有本 PR 改动的 main 上同样失败,与本 PR 无关。
  • node shared/plugins/scripts/sdk-e2e.mjs 没有运行:本 PR 没有改插件后端协议。
  • 没有在 Windows 和 Linux 真机上运行测试,只做了 Windows 目标的 clippy。

- 删除没有调用方的命令名单、函数和常量:AGENT_COMMANDS、
  AGENT_SESSION_COMMANDS、AGENT_LIBRARY_COMMANDS、AGENT_PROVIDER_COMMANDS、
  core::start_lsp_owned、lsp_engine::start_server_owned、
  is_hidden_directory_name、CHANNEL_ROOTS、DIAGNOSTIC_DURATION_MS、
  KNOWN_PLATFORMS、LIFECYCLE_EVENTS、devcontainer_up_with
- 去掉两个未使用的依赖:agent-runtime 的 lithe-plugin-model、
  core 的 lithe-plugin-ui
- 注释和文档里“两个宿主”“Windows 前端”等说法改为当前的单一桌面端
- rust-core-api.md 的 C ABI 清单补上 lithe_core_is_plain_text 和
  lithe_core_execute_document_json,并指向头文件

Refs 1lck/Lithe-IDEA#2651
@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review December 3, 2026 07:17
@xiaoyumuxi
xiaoyumuxi merged commit a05b8c4 into main Dec 3, 2026
11 of 12 checks passed

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant